<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
      <template #operationAfterExtend="{ record }">
        <a-link @click="handleClick(record)">人脸识别记录</a-link>
      </template>
    </ma-crud>
    <a-drawer
      :width="1500"
      :visible="visible"
      @ok="handleOk"
      @cancel="handleCancel"
      unmountOnClose
    >
      <template #title>人脸识别记录</template>
      <recognizeInfo v-if="visible"> </recognizeInfo>
    </a-drawer>
  </div>
</template>
<script setup>
import { ref, reactive } from "vue";
import secureDangerstaffManage from "@/api/secure/secureDangerstaffManage";
import recognizeInfo from "@/views/secure/recognizeInfo/index.vue";
import { Message } from "@arco-design/web-vue";
import tool from "@/utils/tool";
import * as common from "@/utils/common";

const crudRef = ref();
const visible = ref(false);

const handleClick = (row) => {
  visible.value = true;
};
const handleOk = () => {
  visible.value = false;
};
const handleCancel = () => {
  visible.value = false;
};
const numberOperation = (newValue, id, numberName) => {
  secureDangerstaffManage
    .numberOperation({ id, numberName, numberValue: newValue })
    .then((res) => {
      res.success && Message.success(res.message);
    })
    .catch((e) => {
      console.log(e);
    });
};

const switchStatus = (statusValue, id, statusName) => {
  secureDangerstaffManage
    .changeStatus({ id, statusName, statusValue })
    .then((res) => {
      res.success && Message.success(res.message);
    })
    .catch((e) => {
      console.log(e);
    });
};

const options = reactive({
  id: "flyos_secure_dangerstaff_manage",
  rowSelection: {
    showCheckedAll: true,
  },
  pk: "id",
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: "modal",
    width: 600,
  },
  api: secureDangerstaffManage.getList,
  recycleApi: secureDangerstaffManage.getRecycleList,
  add: {
    show: true,
    api: secureDangerstaffManage.save,
    auth: ["secure:dangerstaffManage:save"],
  },
  edit: {
    show: true,
    api: secureDangerstaffManage.update,
    auth: ["secure:dangerstaffManage:update"],
  },
  delete: {
    show: true,
    api: secureDangerstaffManage.deletes,
    auth: ["secure:dangerstaffManage:delete"],
    realApi: secureDangerstaffManage.realDeletes,
    realAuth: ["secure:dangerstaffManage:realDeletes"],
  },
  recovery: {
    show: true,
    api: secureDangerstaffManage.recoverys,
    auth: ["secure:dangerstaffManage:recovery"],
  },
  import: {
    show: true,
    url: "secure/dangerstaffManage/import",
    templateUrl: "secure/dangerstaffManage/downloadTemplate",
    auth: ["secure:dangerstaffManage:import"],
  },
  export: {
    show: true,
    url: "secure/dangerstaffManage/export",
    auth: ["secure:dangerstaffManage:export"],
  },
});

const columns = reactive([
  {
    title: "ID",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入ID",
    },
  },
  {
    title: "编号",
    dataIndex: "staff_id",
    formType: "input",
  },
  {
    title: "姓名",
    dataIndex: "staff_name",
    formType: "input",
    search: true,
  },
  {
    title: "身份证号",
    dataIndex: "card_no",
    formType: "input",
  },
  {
    title: "证件名称",
    dataIndex: "card_name",
    formType: "input",
  },
  {
    title: "手机号",
    dataIndex: "phone",
    formType: "input",
  },
  {
    title: "上传证件",
    dataIndex: "uploao_card",
    formType: "upload",
    onlyData: true,
    multiple: false,
    returnType: "url",
  },
  {
    title: "上传头像",
    dataIndex: "uploao_avatar",
    formType: "upload",
    onlyData: true,
    multiple: false,
    returnType: "url",
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true,
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true,
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true,
  },
]);
</script>
<script>
export default { name: "secure:dangerstaffManage" };
</script>
